package com.shang.service.impl;

import com.shang.dao.CommentDao;
import com.shang.dto.CommentDTO;
import com.shang.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    private CommentDao commentDao;

    @Override
    public List<CommentDTO> getCommentsByPage(int pageNum, int pageSize) {
        List<CommentDTO> commentList = commentDao.getCommentsByPage(pageNum, pageSize);
        return commentList;
    }

    @Override
    public int getCommentNumber() {
        int commentNumber = commentDao.getCommentNumber();
        return commentNumber;
    }

    @Override
    public int updateCommentValue(long comment_id,int scoreValue) {
        int updateNum = commentDao.updateCommentValue(comment_id, scoreValue);
        return updateNum;
    }

    @Override
    public int updateCommentMark(long comment_id, boolean isMark) {
        int mark;
        if (isMark==true){
            mark=1;
        }
        else {
            mark=0;
        }
        int updateNum = commentDao.updateCommentMark(comment_id, mark);
        return updateNum;
    }

    @Override
    public int addUserMark(String userName, long comment_id, String markTime) {
        int insertNum = commentDao.addUserMark(userName, comment_id, markTime);
        return insertNum;
    }

    @Override
    public boolean checkMark(String userName, long comment_id) {
        boolean check = commentDao.checkMark(userName, comment_id);
        return check;
    }

    @Override
    public int removeMark(String userName, long comment_id) {
        int removeNum = commentDao.removeMark(userName, comment_id);
        return removeNum;
    }

    @Override
    public int getUserMarkNum(String userName) {
        int userMarkNum = commentDao.getUserMarkNum(userName);
        return userMarkNum;
    }

    @Override
    public int getCommentValueById(long comment_id) {
        int commentValueById = commentDao.getCommentValueById(comment_id);
        return commentValueById;
    }
}
